//
//  NSBundle+AppInfo.m
//  MXDK
//
//  Created by guoshikeji_a on 2018/3/23.
//  Copyright © 2018年 chen. All rights reserved.
//

#import "NSBundle+AppInfo.h"

@implementation NSBundle (AppInfo)

+ (NSString *)appIconName {
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    NSDictionary *bundleIcons = infoDict[@"CFBundleIcons"];
    if (bundleIcons) {
        NSDictionary *bundlePrimaryIcon = bundleIcons[@"CFBundlePrimaryIcon"];
        if (bundlePrimaryIcon) {
            NSArray *bundleIconFiles = bundlePrimaryIcon[@"CFBundleIconFiles"];
            if (bundleIconFiles.count) {
                id iconLastName = [bundleIconFiles lastObject];
                if ([iconLastName isKindOfClass:[NSString class]]) {
                    return iconLastName;
                }
            }
        }
    }
    return nil;
}

+ (NSString *)appDisplayName {//CFBundleDisplayName
    NSString *name = NSLocalizedStringFromTable(@"CFBundleDisplayName", @"infoPlist", nil);
    if (name) {
        return name;
    }
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    return infoDict[@"CFBundleDisplayName"];
}


/**
 当前版本号
 */
+ (NSString *)appCurrentVersionNumber {
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    return infoDict[@"CFBundleShortVersionString"];
}

@end
